#define PC

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

#if PC
using System.Diagnostics;
#endif

namespace TimeWar.Objects
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Planet : ActiveGameObject
    {

        private Texture2D planetMouseOver;
        private string mouseOverFileLocation;
        


        public Planet(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }


        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        public void setCursorOverContentLocation(string contentLocation)
        {
            mouseOverFileLocation = contentLocation;
        }



        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            //if (isMouseOverPlanet(Mouse.GetState().

            if (isObjClicked())
            {
                //set state
#if PC
                Trace.WriteLine("[" + DateTime.Now + "]: Planet was clicked on during Update().");
#endif

            }




            base.Update(gameTime);
        }

        public override void Draw(GraphicsDeviceManager graphics, GameTime gameTime, SpriteBatch gameSpriteBatch)
        {
            //throw new Exception("The method or operation is not implemented.");
            
            Vector2 cursorPosition = currCursor.getCurrLocation();

#if PC
            Trace.WriteLine("[" + DateTime.Now + "]: Inside Planet.Draw().");
#endif
            Vector2 screenCenter = new Vector2((graphics.GraphicsDevice.Viewport.Width - planetMouseOver.Width) / 2, (graphics.GraphicsDevice.Viewport.Height - planetMouseOver.Height) / 2);

            if (isObjClicked())
            {
                //draw team selection menu
#if PC
                Trace.WriteLine("[" + DateTime.Now + "]: Planet was clicked on during Update().");
#endif

            }
            else
            {
                if (isCursorOverObject())
                {
                    gameSpriteBatch.Draw(planetMouseOver, screenCenter, Color.White);
                }
                gameSpriteBatch.Draw(primaryGraphic, currLocation, Color.White);

                if (childGameObjects != null && childGameObjects.Count > 0)
                {

                    foreach (ActiveGameObject obj in childGameObjects)
                    {
                        obj.Draw(graphics, gameTime, gameSpriteBatch);
                    }
                }

            }


            
        }

        public override void LoadContent(GraphicsDevice graphicsDevice)
        {
            //throw new Exception("The method or operation is not implemented.");
            primaryGraphic = Game.Content.Load<Texture2D>(primaryGraphicLocation);
            planetMouseOver = Game.Content.Load<Texture2D>(mouseOverFileLocation);
        }



    }
}